#ifndef NDD_H
#define NDD_H

#include "ui_prj_w.h"
#include "ui_dialog_w.h"
#include <QFileDialog>
#include <QList>
#include <QObject>
#include <tinyxml.h>
#include <boost/regex.hpp>

class AskDoubleDialog : public QDialog, public Ui::Dialog
{
	Q_OBJECT

private slots:
	void on_lineEdit_textChanged();
	void on_lineEdit_editingFinished();

public:
	AskDoubleDialog(QWidget *parent = 0);
	bool checkInput(QString &inpLine);
};

class Model : public QMainWindow, private Ui::MainWindow
{
	Q_OBJECT

private:
	QVariant Count;

private slots:
	void on_btnAddSub_clicked();
	void on_btnAdd_clicked();
	void on_btnCorrect_clicked();
	void on_btnNew_clicked();
	void on_btnDelete_clicked();
	void on_actionSave_triggered();
	void on_actionLoad_triggered();
	void on_actionExit_triggered();

public:
	Model();
	void addItem(QString &s, bool form);
	int showItemChangeDialog();
	int Delete(QTreeWidgetItem * currentItem = 0);

private:
	QString CounterToCaption();
	QList<QTreeWidgetItem*> CollectItems(QTreeWidgetItem * curItem);	
	void CollectItems(QTreeWidgetItem * curItem, QList<QTreeWidgetItem*> &list);
	bool saveTree(const QString &FName);
	void pickUpChildren(QTreeWidgetItem * header, TiXmlElement * parent, QVariant &);
	bool loadTree(QString &FileName);
	void buildTree(QTreeWidgetItem * item, TiXmlNode * node);
	bool fileSaveDialog(QString &FileName);
	bool fileOpenDialog(QString &FileName);
};

#endif